home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / v cisle / htttrack / httrack-3.41-3.exe / {app} / src_win / WinHTTrack / Wid1.cpp < prev    next >
C/C++ Source or Header  |  2006-08-19  |  26KB  |  860 lines

  1. // Wid1.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <afxole.h>
  6. #include "oledlg.h"
  7. #include "afxodlgs.h"
  8.  
  9. #include "Shell.h"
  10. #include "Wid1.h"
  11.  
  12. #include "NewProj.h"
  13. #include "XSHBrowseForFolder.h"
  14.  
  15. extern "C" {
  16.   #include "HTTrackInterface.h"
  17. }
  18.  
  19. #include "about.h"
  20. #include "InsertUrl.h"
  21.  
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27.  
  28. extern CNewProj* dialog0;
  29.  
  30. extern int binput(char* buff,char* s,int max);
  31.  
  32. extern int check_continue(char* path_log);
  33. extern int cmdl_opt(char* s);
  34. extern void Write_profile(CString path,int load_path);
  35. extern void Read_profile(CString path,int load_path);
  36. extern CShellApp* CShellApp_app;
  37.  
  38. // Helper
  39. extern LaunchHelp* HtsHelper;
  40.  
  41. // reference sur objet
  42. extern Wid1* dialog1;
  43.  
  44. /* Main WizTab frame */
  45. #include "WizTab.h"
  46. extern CWizTab* this_CWizTab;
  47.  
  48. /* Main splitter frame */
  49. #include "DialogContainer.h"
  50. #include "splitter.h"
  51. extern CSplitterFrame* this_CSplitterFrame;
  52.  
  53. /* Back to FirstInfo */
  54. //#include "FirstInfo.h"
  55.  
  56. // pour lire ini qu'une fois
  57. int first_time=1;
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60. // Wid1 dialog
  61.  
  62.  
  63. /*class FileSelPath : public CFileDialog {
  64. public:
  65.   BOOL OnFileNameOK( ) { return 0; }
  66.   FileSelPath(BOOL a):CFileDialog(a) { };
  67. };*/
  68.  
  69. IMPLEMENT_DYNCREATE(Wid1, CPropertyPage)
  70.  
  71. //Cfilter filter;
  72. CString change(CString,char);
  73.  
  74. Wid1::Wid1()
  75.     : CPropertyPage(Wid1::IDD)
  76. {
  77.   dialog1=this;    /* NOTER REFERENCE */
  78.   cancel=0;
  79.     //{{AFX_DATA_INIT(Wid1)
  80.     m_C1 = -1;
  81.     m_urls = _T("");
  82.   m_todo = 0;
  83.     m_infomain = _T("");
  84.     m_filelist = _T("");
  85.     //}}AFX_DATA_INIT
  86. }
  87.  
  88. Wid1::~Wid1() {
  89.   dialog1=NULL;
  90. }
  91.  
  92. void Wid1::DoDataExchange(CDataExchange* pDX)
  93. {
  94.     CPropertyPage::DoDataExchange(pDX);
  95.     //{{AFX_DATA_MAP(Wid1)
  96.     DDX_Control(pDX, IDC_todo, m_ctl_todo);
  97.     DDX_Text(pDX, IDC_URL, m_urls);
  98.     DDX_CBIndex(pDX, IDC_todo, m_todo);
  99.     DDX_Text(pDX, IDC_INFOMAIN, m_infomain);
  100.     DDX_Text(pDX, IDC_filelist, m_filelist);
  101.     //}}AFX_DATA_MAP
  102. }
  103.  
  104. //IMPLEMENT_DYNAMIC(Wid1, CPropertyPage)
  105.  
  106. #define wm_CEasyDropTargetCallback (WM_USER + 1)
  107. BEGIN_MESSAGE_MAP(Wid1, CPropertyPage)
  108.     //{{AFX_MSG_MAP(Wid1)
  109.     ON_EN_CHANGE(IDC_URL, OnChangeUrl)
  110.     ON_CBN_SELCHANGE(IDC_todo, OnSelchangetodo)
  111.     ON_WM_CREATE()
  112.     ON_WM_HELPINFO()
  113.     ON_BN_CLICKED(ID_setopt, Onsetopt)
  114.     ON_BN_CLICKED(IDC_login2, Onlogin2)
  115.     ON_BN_CLICKED(IDC_br, Onbr)
  116.   ON_WM_DROPFILES()
  117.     ON_WM_DRAWITEM()
  118.     ON_WM_SHOWWINDOW()
  119.     ON_EN_CHANGE(IDC_filelist, OnChangefilelist)
  120.     //}}AFX_MSG_MAP
  121.     ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  122.     ON_COMMAND(ID_HELP,OnHelpInfo2)
  123.     //ON_COMMAND(ID_CONTEXT_HELP,OnContextHelp)
  124.     ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  125.   //
  126.   ON_BN_CLICKED(ID_LOAD_OPTIONS,OnLoadprofile)
  127.   ON_BN_CLICKED(ID_FILE_SAVE_OPTIONS_AS,OnSaveprofile)
  128.     ON_BN_CLICKED(ID_LoadDefaultOptions, OnLoaddefault)
  129.     ON_BN_CLICKED(ID_SaveDefaultOptions, OnSavedefault)
  130.     ON_BN_CLICKED(ID_ClearDefaultOptions,OnResetdefault)
  131.     //ON_BN_CLICKED(ID_NewProjectImport, OnNewProject)
  132.     ON_BN_CLICKED(ID_SaveProject, OnSaveProject)
  133.   ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  134.   //
  135.   ON_MESSAGE( wm_CEasyDropTargetCallback, DragDropText)
  136. END_MESSAGE_MAP()
  137.  
  138. /////////////////////////////////////////////////////////////////////////////
  139. // Wid1 message handlers
  140.  
  141. BOOL Wid1::OnInitDialog( ) {
  142.   CPropertyPage::OnInitDialog();
  143.   EnableToolTips(true);     // TOOL TIPS
  144.  
  145.   // inits aprΦs affichage
  146.   url_status=-1;
  147.   filelist_status=-1;
  148.   //prox_status=-1;
  149.   log_flip=-1;
  150.   mir_status=-1;
  151.   proj_status=-1;
  152.   continue_status=-1;
  153.   OnChangeUrl();
  154.   OnChangefilelist();
  155.   //OnChangeprox();  // update disabled/normal
  156.   //OnSelchangedepth();  // update disabled/normal
  157.   OnSelchangetodo();
  158.  
  159.   // Patcher l'interface pour les Franτais ;-)
  160.   if (LANG_T(-1)) {    // Patcher en franτais
  161.     //SetDlgItemTextCP(this, ,"");
  162.     SetWindowTextCP(this,  LANG(LANG_G30)); // "Bienvenue dans WinHTTrack!");
  163.     SetDlgItemTextCP(this, IDC_STATIC_action,LANG(LANG_G31)); // "Action:");
  164.     //SetDlgItemTextCP(this, IDC_STATIC_filters,LANG(LANG_G33)); // "Filtres (refuser/accepter liens) :");
  165.     SetDlgItemTextCP(this, IDC_STATIC_filters2,LANG(LANG_G41)); // "Options & prefs :");
  166.     SetDlgItemTextCP(this, IDC_STATIC_paths,LANG(LANG_G34)); // "Chemins");
  167.     //SetDlgItemTextCP(this, IDC_regdef,LANG(LANG_G37)); // "Sauver prΘfs");
  168.     //SetDlgItemTextCP(this, IDOK,LANG(LANG_NEXT )); // "SUIVANT ->");
  169.     //SetDlgItemTextCP(this, IDC_avant,LANG(LANG_BACK));
  170.     //SetDlgItemTextCP(this, IDCANCEL,LANG(LANG_QUIT));  // exit 
  171.     //SetDlgItemTextCP(this, IDfilter,LANG(LANG_G39)); // "DΘfinir..");
  172.     SetDlgItemTextCP(this, ID_setopt,LANG(LANG_G40)); // "DΘfinir les options..");
  173.     //SetDlgItemTextCP(this, IDC_mirtitle2,LANG(LANG_G42)); // "Nom du projet");
  174.     SetDlgItemTextCP(this, IDC_login2,LANG_G43);
  175.     //SetDlgItemTextCP(this, IDC_urls,LANG_G44);
  176.     SetDlgItemTextCP(this, IDC_STATIC_webaddr,LANG_G44);
  177.     SetCombo(this,IDC_todo,LISTDEF_10);
  178.   }
  179.  
  180.   // inits
  181.   LAST_ACTION = m_ctl_todo.GetCount()-1;  // dernier item (update)
  182.  
  183.   // fichier ini
  184.   // lire default
  185.   if (first_time) {
  186.     first_time=0;
  187.  
  188.     //SetDlgItemTextCP(this, IDC_INFOMAIN,"Please select an action, and fill the addresse(s) in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below");
  189.  
  190.     /*
  191.     CString strSection       = "DefaultValues";    
  192.     CWinApp* pApp = AfxGetApp();
  193.     CString st;
  194.     int n;
  195.     */
  196.  
  197.     /*
  198.     if ((n = pApp->GetProfileInt(strSection, "Action",CB_ERR)) != CB_ERR)
  199.       m_ctl_todo.SetCurSel(n);
  200.  
  201.     if ((st = pApp->GetProfileString(strSection, "Depth")))
  202.       SetDlgItemTextCP(this, IDC_depth,st);    
  203.     */
  204.  
  205.     /*
  206.     if ((st = pApp->GetProfileString(strSection, "MirrorPath","default")) != (CString) "default")
  207.       SetDlgItemTextCP(this, IDC_pthmir,st);
  208.     if ((st = pApp->GetProfileString(strSection, "LogPath","default")) != (CString) "default")
  209.       SetDlgItemTextCP(this, IDC_pathlog,st);
  210.     */
  211.  
  212.     // Infos la 1ere fois!
  213.     /*if (!pApp->GetProfileInt("Interface","FirstRun",0)) {
  214.       pApp->WriteProfileInt("Interface","FirstRun",1);
  215.       Onipabout();
  216.     }*/
  217.  
  218.   } else {
  219.     log_flip=0;
  220.   }
  221.   // fichier ini  
  222.  
  223.   //OnChangepathlog();  // update rΘpertoire log
  224.   //OnChangepthmir();  // update rΘpertoire miroir
  225.  
  226.   return TRUE;
  227. }
  228.  
  229. void Wid1::AfterInitDialog( ) {
  230.   WHTT_LOCATION("Wid1");
  231.   if (load_after_changes) {
  232.     AfterChangepathlog();
  233.     OnSelchangetodo();
  234.     load_after_changes=0;
  235.   }
  236.   OnChangeUrl();
  237.   OnChangefilelist();
  238. }
  239.  
  240. /*
  241. void Wid1::Onurls() {
  242.   CleanUrls();
  243. }
  244. */
  245.  
  246. // nettoyer les URLs
  247. void Wid1::CleanUrls() 
  248. {
  249.   CWaitCursor wait;
  250.   char* tempo, *ch,*str;
  251.   CString    st="";
  252.   // TODO: Add your control notification handler code here
  253.   
  254.   GetDlgItemText(IDC_URL,st);
  255.   tempo=(char*) malloc(st.GetLength()+1);
  256.   ch=(char*) malloc(st.GetLength()+1);
  257.   str=(char*) malloc(st.GetLength()*2+8192);
  258.   tempo[0]=ch[0]=str[0]='\0';
  259.   if ( (tempo) && (ch) && (str) ) {
  260.     strcpybuff(tempo,st);
  261.     int i;
  262.     for(i=0;i < (int) strlen(tempo);i++)  {
  263.       if(tempo[i]==10) tempo[i]=' ';
  264.       else if(tempo[i]==13) tempo[i]=' ';
  265.     }
  266.     
  267.     strcpybuff(ch,"");
  268.     int j=0;
  269.     for(i=0;i <= (int) strlen(tempo);i++) {
  270.       if ((tempo[i]==' ') || (tempo[i]==0)) {
  271.         ch[j++]='\0';
  272.         if ((strlen(ch)>0) && ((int) strlen(ch)<HTS_URLMAXSIZE) ) {
  273.           // vΘrifier URL
  274.           /*
  275.           char adr[HTS_URLMAXSIZE*2],fil[HTS_URLMAXSIZE*2];
  276.           adr[0]=fil[0]='\0';
  277.           if (ident_url_absolute(ch,adr,fil)==-1) {
  278.             htsblk r;
  279.             char loc[HTS_URLMAXSIZE*2]; loc[0]='\0';    // Θventuelle nouvelle position
  280.             r=http_test(ch,fil,loc);
  281.             if (HTTP_IS_REDIRECT(r.statuscode)) {
  282.               strcpybuff(ch,loc);
  283.             }
  284.           }
  285.           */
  286.           // recopier adresse
  287.           if (strstr(ch,":/")==NULL) {
  288.             strcatbuff(str,"http://");
  289.           }
  290.           strcatbuff(str,ch);
  291.           strcatbuff(str,"\x0d\x0a");
  292.         }
  293.         j=0;
  294.       } else ch[j++]=tempo[i];
  295.     }
  296.     SetDlgItemTextCP(this, IDC_URL,str);
  297.     free(tempo);
  298.     free(ch);
  299.     free(str);
  300.   } else
  301.     AfxMessageBox(LANG(LANG_DIAL10));
  302.   //m_urls=str;
  303. }
  304.  
  305. void Wid1::OnChangeUrl()
  306. {
  307.   CString st="";
  308.   //char tempo[8192];
  309.   char* tempo;
  310.     // TODO: If this is a RICHEDIT control, the control will not
  311.     // send this notification unless you override the CPropertyPage::OnInitDialog()
  312.     // function to send the EM_SETEVENTMASK message to the control
  313.   // with the ENM_CHANGE flag ORed into the lParam mask.
  314.   
  315.   // TODO: Add your control notification handler code here
  316.   GetDlgItemText(IDC_URL,st);
  317.   tempo=(char*) malloc(st.GetLength()+1);
  318.   if (tempo) {
  319.     strcpybuff(tempo,st);
  320.     int ex=0;
  321.     do {
  322.       if (strlen(tempo)>0) {
  323.         switch (tempo[strlen(tempo)-1]) {
  324.         case 10: case 13: case 32: tempo[strlen(tempo)-1]='\0';
  325.           break;
  326.         default: ex=1;
  327.           break;
  328.         }
  329.       } else ex=1;
  330.     } while(!ex);
  331.     
  332.     if ( ((strlen(tempo)>0) ) != url_status) { // || (m_ctl_todo.GetCurSel()==4)
  333.       url_status=!url_status;
  334.       
  335.       if (url_status) {
  336.         //m_ctl_next.ModifyStyle(WS_DISABLED,0);
  337.       }
  338.       else {
  339.         //m_ctl_next.ModifyStyle(0,WS_DISABLED);
  340.       }
  341.       //m_ctl_next.RedrawWindow();
  342.     }
  343.     free(tempo); tempo=NULL;
  344.   } else
  345.     AfxMessageBox(LANG(LANG_DIAL10));
  346. }
  347.  
  348. void Wid1::Refresh() {
  349.   OnChangeUrl();
  350.   //OnChangeprox();  // update disabled/normal
  351.   //OnSelchangedepth();  // update disabled/normal
  352. }
  353.  
  354. void Wid1::OnSelchangetodo() 
  355. {
  356.   int r;
  357.   r = m_ctl_todo.GetCurSel();
  358.   if (r!=CB_ERR) {
  359.     switch(r) {
  360.     case 0:
  361.       SetDlgItemTextCP(this, IDC_INFOMAIN,
  362.       LANG(LANG_G2 /*"Mirror mode, fill the addresse(s) in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below",
  363.       "Mode miroir, remplissez les addresse(s) dans la liste d'URLs.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  364.       );
  365.       break;
  366.     case 1:
  367.       SetDlgItemTextCP(this, IDC_INFOMAIN,
  368.       LANG(LANG_G3 /* "Mirror mode with wizard (asks questions), fill the addresse(s) in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below",
  369.       "Mode miroir semi automatique (pose des questions), remplissez les addresse(s) dans la liste d'URLs.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  370.       );
  371.       break;
  372.     case 2:
  373.       SetDlgItemTextCP(this, IDC_INFOMAIN,
  374.       LANG(LANG_G4 /* "Get files mode, fill the addresse(s) of the files in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below",
  375.       "Mode tΘlΘchargement de fichier, remplissez les addresse(s) des fichiers dans la liste d'URLs.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  376.       );
  377.       SetDlgItemTextCP(this, IDC_depth,"");
  378.       break;
  379.     case 3:
  380.       SetDlgItemTextCP(this, IDC_INFOMAIN,
  381.         LANG(LANG_G1B)
  382.         );
  383.       SetDlgItemTextCP(this, IDC_depth,"");
  384.       break;
  385.     case 4:
  386.       SetDlgItemTextCP(this, IDC_INFOMAIN,
  387.       LANG(LANG_G5 /* "Test links mode, fill the addresse(s) of the pages containing links to test in the URL box.\x0d\x0aThe log report will be saved in the location indicated below",
  388.       "Mode test de liens, remplissez les adresse(s) des pages contenant les liens α tester dans la liste d'URLs.\x0d\x0aLes fichiers d'audit seront sauvΘs α l'emplacement indiquΘ plus bas"*/)
  389.       );
  390.       SetDlgItemTextCP(this, IDC_depth,"");
  391.       break;
  392.     default:
  393.       if (r == LAST_ACTION )
  394.         SetDlgItemTextCP(this, IDC_INFOMAIN,
  395.         LANG(LANG_G6 /* "Update/Continue a mirror mode, check addresse(s) in the URL box, then click to the 'NEXT' button and check parameters.\x0d\x0aThe mirror will be saved in the location indicated below",
  396.         "Mode mise α jour/continuer un miroir, vΘrifiez les adresse(s) dans la liste d'URLs, puis cliquez sur le bouton 'NEXT' et vΘrifiez les paramΦtres.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  397.         );
  398.       else if (r == LAST_ACTION-1 )
  399.         SetDlgItemTextCP(this, IDC_INFOMAIN,
  400.         LANG(LANG_G6b /* "Update/Continue a mirror mode, check addresse(s) in the URL box, then click to the 'NEXT' button and check parameters.\x0d\x0aThe mirror will be saved in the location indicated below",
  401.         "Mode mise α jour/continuer un miroir, vΘrifiez les adresse(s) dans la liste d'URLs, puis cliquez sur le bouton 'NEXT' et vΘrifiez les paramΦtres.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  402.         );
  403.       break;
  404.     }
  405.     
  406.     if ( ((r==LAST_ACTION)||(r==LAST_ACTION-1)) != continue_status) {
  407.       continue_status=((r==LAST_ACTION)||(r==LAST_ACTION-1));
  408.       OnChangeUrl();
  409.     }
  410.   }
  411.   
  412. }
  413.  
  414.  
  415. void Wid1::OnChangepathlog() {
  416.   load_after_changes=1;
  417. }
  418.  
  419. void Wid1::AfterChangepathlog() 
  420. {
  421.   CString st="";
  422.   char tempo[8192];
  423.   BOOL modify;
  424.     char catbuff[CATBUFF_SIZE];
  425.  
  426.   strcpybuff(tempo,dialog0->GetPath());
  427.   {
  428.     if (fexist(fconcat(catbuff,tempo,"hts-cache/winprofile.ini"))) {    // un cache est prΘsent
  429.       if (fsize(fconcat(catbuff,tempo,"hts-cache/winprofile.ini"))>0) {   // taille log contr⌠le>0
  430.         int i;
  431.         for(i=0;i<(int) strlen(tempo);i++)
  432.           if (tempo[i]=='/')
  433.             tempo[i]='\\';
  434.           Read_profile(fconcat(catbuff,tempo,"hts-cache\\winprofile.ini"),0);
  435.  
  436.           // peut on modifier?
  437.           int pos=m_ctl_todo.GetCurSel();
  438.           if ((pos==LAST_ACTION) || (pos==LAST_ACTION-1) || (pos==0))
  439.             modify=true;
  440.           else
  441.             modify=false;
  442.           
  443.           // existe: update
  444.           if (
  445.             fexist(fconcat(catbuff,tempo,"hts-cache/new.zip"))
  446.             ||
  447.             (fexist(fconcat(catbuff,tempo,"hts-cache/new.dat"))) && (fexist(fconcat(catbuff,tempo,"hts-cache/new.ndx")))
  448.             ) {  // il existe dΘja un cache prΘcΘdent.. renommer
  449.             if (modify) {
  450.               if (
  451.                 (!fexist(fconcat(catbuff,tempo,"hts-in_progress.lock")))
  452.                 &&
  453.                 (!fexist(fconcat(catbuff,tempo,"hts-cache/interrupted.lock")))
  454.                 )
  455.                 m_ctl_todo.SetCurSel(LAST_ACTION);
  456.               else
  457.                 m_ctl_todo.SetCurSel(LAST_ACTION-1);
  458.             }
  459.             log_flip=1;
  460.           } else if (log_flip) {
  461.             if (modify)
  462.               m_ctl_todo.SetCurSel(0);
  463.             log_flip = 0;
  464.           }
  465.           OnSelchangetodo();
  466.       }
  467.     } else if (log_flip) {
  468.       m_ctl_todo.SetCurSel(0);
  469.       log_flip = 0;
  470.     }
  471.   }
  472. }
  473. /*
  474. void Wid1::OnClose() 
  475. {
  476.   // TODO: Add your message handler code here and/or call default
  477.   //Onfin();
  478.   //::OnClose();
  479.   if (AfxMessageBox(
  480.   LANG(LANG_J1)
  481.   ,MB_OKCANCEL)==IDOK) {
  482.     if (Save_current_profile(1)!=IDCANCEL) {
  483.       cancel=1;
  484.       CPropertyPage::OnCancel();
  485.     }
  486.   }
  487. }
  488. */
  489.  
  490.  
  491.  
  492. // ------------------------------------------------------------
  493. // TOOL TIPS
  494. //
  495. // ajouter dans le .cpp:
  496. // remplacer les deux Wid1:: par le nom de la classe::
  497. // dans la message map, ajouter
  498. // ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  499. // dans initdialog ajouter
  500. // EnableToolTips(true);     // TOOL TIPS
  501. //
  502. // ajouter dans le .h:
  503. // char* GetTip(int id);
  504. // et en generated message map
  505. // afx_msg BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
  506. BOOL Wid1::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
  507. {
  508.   TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
  509.   UINT_PTR nID = pNMHDR->idFrom;
  510.   if (pTTT->uFlags & TTF_IDISHWND)
  511.   {
  512.     // idFrom is actually the HWND of the tool
  513.     nID = ::GetDlgCtrlID((HWND)nID);
  514.     if(nID)
  515.     {
  516.       char* st = GetTip((int) nID);
  517.       if (st != "") {
  518.         pTTT->lpszText = st;
  519.         pTTT->hinst = AfxGetResourceHandle();
  520.         return(TRUE);
  521.       }
  522.     }
  523.   }
  524.   return(FALSE);
  525. }
  526. char* Wid1::GetTip(int ID)
  527. {
  528.   switch(ID) {
  529.     case IDC_todo:  return LANG(LANG_G9); break; // "Choose an action","Choisissez une action"); break; 
  530.     case IDC_depth: return LANG(LANG_G10); break; // "Maximum link depth to scan","Profondeur maximale"); break;
  531.     case IDC_URL:   return LANG(LANG_G11); break; // "Enter addresses here","Entrez les adresses ici"); break;
  532.     //case IDC_urls:  return LANG(LANG_G12); break; // "Check spelling","VΘrifier syntaxe"); break;
  533.     //case IDfilter:  return LANG(LANG_G13); break; // "Define additional filters","DΘfinir les filtres supplΘmentaires"); break;
  534.     //case IDC_pathlog:  return LANG(LANG_G16); break; // "Path","Chemin"); break;
  535.     //case IDC_br2:      return LANG(LANG_G17); break; // "Select path","Choix du chemin"); break;
  536.     //case IDC_pthmir:   return LANG(LANG_G18); break; // "Path","Chemin"); break;
  537.     //case IDC_br1:      return LANG(LANG_G19); break; // "Select path","Choix du chemin"); break;
  538.     case IDCANCEL:     return LANG(LANG_G20); break; // "Quit WinHTTrack","Quittter WinHTTrack"); break;
  539.     case IDC_ipabout:  return LANG(LANG_G21); break; // "About WinHTTrack","A propos de WinHTTrack"); break;
  540.     case IDC_regdef:   return LANG(LANG_G22); break; // "Save preferences as default values","Sauver les rΘglages par dΘfaut"); break;
  541.     case IDOK:         return LANG(LANG_G23); break; // "Click to continue","Clic pour continuer"); break;
  542.     case IDC_avant:     return LANG_TIPPREV; break;
  543.     case ID_setopt:    return LANG(LANG_G24); break; // "Click to define option","Clic pour dΘfinir les options"); break;
  544.     case IDC_login2:   return LANG_G24b; break;
  545.     case IDC_filelist: return LANG_G24c; break;
  546.     //case : return ""; break;
  547.   }
  548.   return "";
  549. }
  550. // TOOL TIPS
  551. // ------------------------------------------------------------
  552.  
  553.  
  554. /*
  555. void Wid1::OnDropFiles(HDROP hDropInfo) 
  556. {
  557.   int nf;
  558.   int i;
  559.   nf=DragQueryFile(hDropInfo,0xFFFFFFFF,NULL,0);    // nbre de fichiers
  560.  
  561.   for(i=0;i<nf;i++) {
  562.     char* buff;
  563.     int size;
  564.     size=DragQueryFile(hDropInfo,i,NULL,0);    // taille buffer nΘcessaire
  565.     if (size>0) {
  566.       size+=16;    // marge de sΘcuritΘ
  567.       buff=(char*) calloc(size,1);
  568.       if (buff) {
  569.         if (DragQueryFile(hDropInfo,i,buff,size)>0) {    // ok copiΘ
  570.           AfxMessageBox(buff,MB_OKCANCEL+MB_ICONQUESTION);
  571.         }
  572.         free(buff);
  573.       }
  574.     }
  575.   }
  576.  
  577.   CPropertyPage::OnDropFiles(hDropInfo);
  578. }
  579. */
  580.  
  581. int Wid1::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  582. {
  583.     if (CPropertyPage::OnCreate(lpCreateStruct) == -1)
  584.         return -1;
  585.  
  586.   // Drag&Drop
  587.   drag=new CEasyDropTarget(this);
  588.   if (drag->IsRegistered()) {
  589.     drag->SetTextCallback(wm_CEasyDropTargetCallback);
  590.   }
  591.     
  592.     return 0;
  593. }
  594.  
  595.  
  596. CString Wid1::TextToUrl(CString st,CLIPFORMAT cfFormat) {
  597.   // yop
  598.   // on va convertir les chaines α la suite
  599.   CString res;
  600.   if (cfFormat==CF_TEXT) {
  601.     char *buff, *last;
  602.     for(buff = st.GetBuffer(0), last = buff ; *buff != '\0' ; buff++) {
  603.       if (*buff == 10 || *buff == 13) {
  604.         *buff = 0;
  605.         if (*last) {
  606.           res += last;
  607.           res += "\r\n";
  608.         }
  609.         last = buff + 1;
  610.       }
  611.     }
  612.     return res;
  613.   }
  614.   else if (cfFormat==CF_HDROP) {
  615.     char* last = st.GetBuffer(0);
  616.     int len = (int) strlen(last);
  617.     if (stricmp(last + len - 4, ".url") == 0) {
  618.       FILE* fp = fopen(last, "rb");
  619.       if (fp != NULL) {
  620.         char line[256];
  621.         if (linput(fp, line, sizeof(line) - 2) > 0
  622.           && linput(fp, line, sizeof(line) - 2) > 0)
  623.         {
  624.           /* BASEURL=http://.. */
  625.           char* pos = strchr(line, '=');
  626.           if (pos != NULL) {
  627.             res += (pos + 1);
  628.             res += "\r\n";
  629.           }
  630.         }
  631.         fclose(fp);
  632.       } else {
  633.         res += last;
  634.         res += "\r\n";
  635.       }
  636.     } 
  637.     else if (st.GetLength()<256) {
  638.       char s[256];
  639.       strcpybuff(s,st);
  640.       escape_check_url(s);     // coder %
  641.       res = "file://";
  642.       res += s;
  643.     }
  644.   }
  645.   return res;
  646. }
  647.  
  648. // Message from CEasyDropTarget
  649. LRESULT Wid1::DragDropText(WPARAM wParam,LPARAM lParam) {
  650.   if (lParam) {
  651.     CString st=*((CString*) lParam);
  652.     CLIPFORMAT cfFormat = (CLIPFORMAT) wParam;
  653.     st=Wid1::TextToUrl(st,cfFormat);
  654.     if (st=="")
  655.       AfxMessageBox(LANG(LANG_DIAL11),MB_SYSTEMMODAL);
  656.     else
  657.       AddText(st);
  658.   }
  659.   return 0;
  660. }
  661.  
  662. // ajout d'URLs
  663. void Wid1::AddText(CString add_st) {
  664.   CString st;
  665.   GetDlgItemText(IDC_URL,st);
  666.   SetDlgItemTextCP(this, IDC_URL,st+"\r\n"+add_st);
  667.   CleanUrls();
  668.   OnChangeUrl();
  669. }
  670.  
  671. // Appel aide
  672. void Wid1::OnHelpInfo2() {
  673.   (void) OnHelpInfo(NULL);
  674. }
  675.  
  676. BOOL Wid1::OnHelpInfo(HELPINFO* dummy) 
  677. {
  678.   //return CPropertyPage::OnHelpInfo(pHelpInfo);
  679.   //AfxGetApp()->WinHelp(0,HELP_FINDER);    // Index du fichier Hlp
  680.   //LaunchHelp(pHelpInfo);
  681.   HtsHelper->Help("step2.html");
  682.   //HtsHelper->Help();
  683.   return true;
  684. }
  685.  
  686. void Wid1::OnLoadprofile() {
  687.   static char BASED_CODE szFilter[256];
  688.   strcpybuff(szFilter,LANG(LANG_G25 /*"WinHTTrack preferences (*.opt)|*.opt||","RΘglages de WinHTTrack (*.opt)|*.opt||"*/));
  689.   CFileDialog* dial = new CFileDialog(true,"opt",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
  690.   if (dial->DoModal() == IDOK) {
  691.     CString st=dial->GetPathName();
  692.     char s[256];
  693.     strcpybuff(s,st);
  694.     if (fexist(s))
  695.       Read_profile(st,1);
  696.     else
  697.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  698.   }
  699.   delete dial;
  700. }
  701.  
  702. void Wid1::OnSaveprofile() {
  703.   static char BASED_CODE szFilter[256];
  704.   strcpybuff(szFilter,LANG(LANG_G25 /*"WinHTTrack preferences (*.opt)|*.opt||","RΘglages de WinHTTrack (*.opt)|*.opt||"*/));
  705.   CFileDialog* dial = new CFileDialog(false,"opt",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
  706.   if (dial->DoModal() == IDOK) {
  707.     CString st=dial->GetPathName();
  708.     Write_profile(st,1);
  709.   }
  710.   delete dial;
  711. }
  712.  
  713. void Wid1::OnLoaddefault() {
  714.   if (AfxMessageBox(LANG(LANG_G27),MB_OKCANCEL)==IDOK) {
  715.     Read_profile("",0);
  716.   }
  717. }
  718.  
  719. void Wid1::OnSavedefault() {
  720.   if (AfxMessageBox(LANG(LANG_G28),MB_OKCANCEL)==IDOK) {
  721.     Write_profile("",0);
  722.   }
  723. }
  724.  
  725. void Wid1::OnResetdefault() {
  726.   if (AfxMessageBox(LANG(LANG_G29),MB_OKCANCEL)==IDOK) {
  727.     Read_profile("<null>",0);    // charger default
  728.     Write_profile("",0);         // et sauver
  729.   }
  730. }
  731.  
  732. /*
  733. void Wid1::OnNewProject() {
  734.   if (AfxMessageBox(LANG(LANG_G1C),MB_OKCANCEL)==IDOK) {
  735.     CWinApp* pApp = AfxGetApp();
  736.     CString name = pApp->m_pszHelpFilePath;
  737.     name=name.Left(name.GetLength()-4);
  738.     name += ".EXE";
  739.     ShellExecute(NULL,"open",name,"","",SW_RESTORE);
  740.     cancel=1;
  741.     EndDialog(1);
  742.   }
  743. }
  744. */
  745.  
  746. void Wid1::OnSaveProject() {
  747.   Save_current_profile(0);
  748. }
  749.  
  750. void Wid1::Onsetopt() 
  751. {
  752.   CShellApp_app->OptPannel();
  753. }
  754.  
  755. /*
  756. HCURSOR Wid1::OnQueryDragIcon() 
  757. {
  758.     // TODO: Add your message handler code here and/or call default
  759.     
  760.     return CPropertyPage::OnQueryDragIcon();
  761. }
  762. */
  763.  
  764. void Wid1::Onlogin2() 
  765. {
  766.     char catbuff[CATBUFF_SIZE];
  767.   CInsertUrl url;
  768.   url.dest_path=dialog0->GetPath();
  769.   if (url.DoModal() == IDOK) {
  770.     if (url.m_urladr.Left(7)=="http://")
  771.       url.m_urladr=url.m_urladr.Mid(7);
  772.     CString st;
  773.     GetDlgItemText(IDC_URL,st);
  774.     if (url.m_urllogin.GetLength()==0) {
  775.       SetDlgItemTextCP(this, IDC_URL,st+"\r\n"+url.m_urladr);
  776.     } else {
  777.       char *a,*b;
  778.       escape_in_url(a=copychar(LPCTSTR(url.m_urllogin)));
  779.       escape_in_url(b=copychar(LPCTSTR(url.m_urlpass)));
  780.       SetDlgItemTextCP(this, IDC_URL,st+"\r\n"+(CString)(a)+":"+(CString)(b)+"@"+url.m_urladr);
  781.     }
  782.     CleanUrls();
  783.     OnChangeUrl();
  784.   }
  785. }
  786.  
  787. LRESULT Wid1::OnWizardNext() {
  788.   CString st;
  789.   UpdateData(TRUE);         // DoDataExchange
  790.   m_urls.TrimLeft(); m_urls.TrimRight();
  791.   m_filelist.TrimLeft(); m_filelist.TrimRight();
  792.   if ((m_urls.GetLength()>0) || (m_filelist.GetLength()>0)) {
  793.     if ((m_todo==LAST_ACTION)||(m_todo==LAST_ACTION-1)) {
  794.       char path[HTS_URLMAXSIZE*2];
  795.       CString st;
  796.       st=dialog0->GetPath();
  797.       strcpybuff(path,st);
  798.       if (check_continue(path))
  799.         return 0;
  800.       else {
  801.         GetDlgItem(IDC_URL)->SetFocus();
  802.         return -1;        // impossible de continuer
  803.       }
  804.     }
  805.   } else {
  806.     GetDlgItem(IDC_URL)->SetFocus();
  807.     return -1;
  808.   }
  809.   return 0;
  810. }
  811.  
  812. BOOL Wid1::OnSetActive( ) {
  813.   //OnInitDialog();
  814.   AfterInitDialog();
  815.   this_CWizTab->SetWizardButtons(PSWIZB_BACK|PSWIZB_NEXT);
  816.   return 1;
  817. }
  818.  
  819. BOOL Wid1::OnQueryCancel( ) {
  820.   this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
  821.   return 0;
  822. }
  823.  
  824. BOOL Wid1::OnKillActive( ) {
  825.   UpdateData(TRUE);         // DoDataExchange
  826.   return 1;
  827. }
  828.  
  829. void Wid1::Onbr() 
  830. {
  831.   static char BASED_CODE szFilter[256];
  832.   strcpybuff(szFilter,LANG(LANG_G25b));
  833.   CFileDialog* dial = new CFileDialog(true,"txt",NULL,OFN_HIDEREADONLY,szFilter);
  834.   if (dial->DoModal() == IDOK) {
  835.     if (fexist((char*)LPCSTR(dial->GetPathName()))) {
  836.       SetDlgItemTextCP(this, IDC_filelist,dial->GetPathName());
  837.     } else {
  838.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  839.       SetDlgItemTextCP(this, IDC_filelist,"");
  840.     }
  841.   }
  842.   delete dial;
  843.   OnChangefilelist();
  844. }
  845.  
  846. void Wid1::OnChangefilelist() 
  847. {
  848.   CString st;
  849.   GetDlgItemText(IDC_filelist,st);
  850.   if ((st.GetLength()>0) != filelist_status) {
  851.     filelist_status=(st.GetLength()>0);
  852.     if (filelist_status) {
  853.       GetDlgItem(IDC_STATIC_filelist)->ModifyStyle(WS_DISABLED,0);
  854.     } else {
  855.       GetDlgItem(IDC_STATIC_filelist)->ModifyStyle(0,WS_DISABLED);
  856.     }
  857.     GetDlgItem(IDC_STATIC_filelist)->RedrawWindow();
  858.   }
  859. }
  860.